/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bash.jcouture.util.swing;

import com.bash.compta.data.Depense;
import java.text.DateFormat;

import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author bashizip
 */
public class DepenseTableModel extends AbstractTableModel {

    private List<Depense> data;
    private String[] colones = {"DATE", "LITTERA", "LIBELE","EFFECTIF", "MONTANT/USD", "MONTANT/FC", "UTILISATEUR", "COMMENTAIRE"};

    public DepenseTableModel(List<Depense> data) {
        this.data = data;
    }

    public DepenseTableModel() {
        
    }

    public int getRowCount() {
        return data.size();
    }

    public int getColumnCount() {
        return colones.length;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Depense c = data.get(rowIndex);

        Object toReturn = null;

        switch (columnIndex) {
            case 0:
                toReturn = DateFormat.getDateInstance(DateFormat.LONG).format(c.getDate());
                break;
            case 1:
                toReturn = c.getCompte().getLittera();
                break;
            case 2:

                toReturn = c.getCompte().getLibelle();
                break;
            case 3:
                toReturn = c.getCompte().getEffectif();
                break;
                case 4:
                toReturn = c.getMontant();
                break;
            case 5:
                toReturn = c.getMontantCDF();
                break;
            case 6:
                toReturn = c.getLogin()==null?"":c.getLogin().getName();
                break;
            case 7:
                toReturn = c.getCommentaire();
                break;

        }
        return toReturn;

    }

    @Override
    public String getColumnName(int column) {
        return colones[column];
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }
}
